@extends('admin::layouts.master')
@section('title')
    反馈列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" id="form1">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 300px;">
                                <input type="text" name="name" placeholder="反馈者名称" value="{{$arr_search['name']}}" autocomplete="off" class="layui-input"></div>
                                <input type="hidden" name="user_id" value="{{$arr_search['user_id']}}">
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>

                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>反馈者</th>
                                <th>联系方式</th>
                                <th>反馈问题</th>
                                <th>反馈时间</th>
                                <th>状态</th>
                                <th>图片</th>
                                <th>处理结果</th>
                                <th>处理管理员</th>
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                            <tr>
                                <td>{{ $value['id'] }}</td>
                                <td><a href="#" data-id="{{$value['user_id']}}" title="查看他的明细" class="click_a">{{ $value['get_user_info']['nickname'] }}</a></td>
                                <td>{{ $value['contact'] }}</td>
                                <td>{{ $value['content'] }}</td>
                                <td>{{ $value['created_at'] }}</td>
                                <td>{{ $value['state']['name'] }}</td>
                                <td>
                                    @foreach($value['imgs'] as $k=>$val)
                                        @if( !empty( $val ) )
                                           <img src="{{ oss_full_url($val) }}" style="width: 100px; height: 100px;" class="Look_img" title="点击查看大图">
                                        @else
                                            暂无图片
                                        @endif
                                    @endforeach
                                </td>
                                <td>{{ $value['remark'] }}</td>
                                <td>{{ $value['admin']['username'] }}</td>
                                <td>
                                    @if( $value['state']['id'] == 1)
                                        <button class="layui-btn"  lay-skin="switch" lay-filter="switchTest" id="fdsfs" data-id="{{$value['id']}}">我要处理</button>
                                    @endif
                                </td>
                            </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;


            //点击图片查看大图
            var bigImgIndex = null;
            $("body").on('click','.Look_img',function(){
                var img_src = $(this).attr('src');
                var img_infor = "<img width='500px' height='600px' border='0' src='" + img_src + "' />";
                bigImgIndex = layer.open({
                    content:img_infor,
                    type:1,
                    area:['auto'],
                    shadeClose: true,
                    shade:[0.4, '#000000'],
                    title:false,
                    closeBtn:true
                });
            });






                $("body").on('click','#fdsfs',function(){
                    var id = $(this).attr('data-id');
                    layer.prompt({title: '请填写处理结果信息', formType: 2}, function(content, index){
                        $.ajax({
                            url: js_url('admin-feedback-update-remark'),
                            type: 'post',
                            data: {id:id,remark:content,'_token': '{{csrf_token()}}'},
                            dataType: "json",
                            success: function (result) {
                                if (result.state === 0) {
                                    layer.msg(result.msg, {time: 1000, icon: 1}, function () {
                                        window.location.reload()//刷新父页面
                                    });
                                } else {
                                    layer.msg(result.msg, {time: 2000, icon: 5});
                                }
                            }
                        });
                    });
                });


                $(".click_a").click(function(){
                    var user_id = $(this).attr('data-id');
                    $("input[name='user_id']").val( user_id );
                    $("input[name='name']").val( $(this).text() );
                    $("#form1").submit();
                })

            })
    </script>
@endsection




